import { createSlice } from '@reduxjs/toolkit'

const initialState = {
  penple: [
    {
      name: '张三',
      tel: '13111111111',
      code: '410257200501060012',
  },{
      name: '李四',
      tel: '13111111112',
      code: '410257200501060013',
  }
  ]
}

export const penpleSlice = createSlice({
  name: 'penple',
  initialState,
  reducers: {
    del(state,action){
      state.penple = state.penple.filter(item => item.code !== action.payload)
    },
    add(state,action){
      state.penple.push(action.payload)
    }
  },
})

// Action creators are generated for each case reducer function
export const {del ,add} = penpleSlice.actions

export default penpleSlice.reducer